<template>
  <div class="head">
    <div class="myHead">
      <div class="headTitle flex">
        <h1>
          <router-link to="home"
            ><img src="@/assets/logo2.png" alt=""
          /></router-link>
        </h1>
        <div class="headRight flex">
          <van-icon
            @click="searchFlag = true"
            name="search"
            size="24"
            color="#71777D"
          />
          <div class="headlink flex">
            <a href="" class="downApp">下载APP</a>
            <router-link class="loginA" :to="{ name: 'login' }"
              >登录</router-link
            >
          </div>
        </div>
      </div>
      <nav>
        <ul class="flex">
          <li><router-link to="home">首页</router-link></li>
          <li><router-link to="free">免费课</router-link></li>
          <li><router-link to="coding">实战课</router-link></li>
          <li>
            <router-link to="class"
              ><van-icon name="diamond" />体系课</router-link
            >
          </li>
          <li><router-link to="live">直播</router-link></li>
          <li><router-link to="read">专栏</router-link></li>
          <!-- <li><router-link to="article">手记</router-link></li> -->
          <!-- <li><router-link to="wiki">慕课教程</router-link></li> -->
        </ul>
      </nav>
    </div>

    <div v-if="searchFlag" class="searchpage">
      <p>
        <van-search
          @search="search"
          v-model="searchValue"
          left-icon=""
          @cancel="searchFlag = false"
          right-icon="search"
          show-action
          placeholder="请输入搜索关键词"
        />
      </p>
    </div>
    <div class="empty"></div>
  </div>
</template>

<script>
export default {
  name: "myHead",
  props: {
    title: String,
  },
  data() {
    return {
      searchFlag: false,
      searchValue: "",
    };
  },
  methods: {
    search(v) {
      console.log(v);
    },
  },
};
</script>

<style scoped lang="scss">
.head {
  position: relative;
  z-index: 999;
  background-color: #fff;
  padding-bottom: 10px;
}
.myHead {
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 20;
  background-color: #fff;
  .headTitle {
    justify-content: space-between;
    width: 100%;
    padding: 14px;

    h1 {
      margin-top: 6px;
      width: 82px;
      height: 24px;
      a,
      img {
        width: 100%;
      }
    }
    .van-icon-search {
      margin-top: 6px;
      margin-right: 6px;
    }
  }
}
.headlink > a {
  font-weight: 700;
  font-size: 0.32rem;
  color: #f01414;
  text-align: center;
  background-color: rgba(242, 13, 13, 0.1);
  padding: 8px 12px;
  display: block;
}
.downApp {
  border-radius: 30px 0 0 30px;
}
.loginA {
  border-radius: 0 30px 30px 0;
}
nav {
  padding-top: 13px;
  padding-left: 20px;
  ul {
    flex-wrap: wrap;
    li {
      margin-right: 24px;
      display: block;
      text-align: left;
      font-weight: 700;
      font-size: 16px;
      color: #71777d;
      line-height: 22px;
      margin-right: 26px;
      margin-bottom: 16px;
      i {
        vertical-align: top;
        margin-right: 4px;
      }
      a {
        color: inherit;
      }
      .router-link-active {
        color: #f01414;
      }
    }
  }
}
.searchpage {
  position: fixed;
  z-index: 999;
  width: 100%;
  height: 100%;
  top: 0;
  background-color: #fff;
  padding: 16px;
}
.empty {
  height: 140px;
  width: 100%;
}
</style>
